package com.hl.mapper;

import com.hl.pojo.*;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface ZixunshiPage {
    List<Consultants> consultants();
    List<Consultants> consultantsbylike(String keyword);
    List<Consultants> zixunshi(Integer id);
//    @Select("select * from expertiseareas where consultant_id=#{consultantId}")
    @Select("select expertiseareas.* from  consultants LEFT JOIN consultant_expertiseareas ON consultants.consultant_id = consultant_expertiseareas.consultant_id LEFT JOIN expertiseareas on expertiseareas.id = consultant_expertiseareas.expertiseareas_id where consultants.consultant_id=#{consultantId}")
    List<Expertiseareas> shanchanglingyu(Integer id);
    @Select("select questions.question_title,replies.reply_content from questions join replies on questions.id = replies.question_id where questions.consultant_id=#{consultantId}")
    List<QuestionsReplies> liuyanhuifu(Integer id);
    @Select("select * from userreviews where consultant_id=#{consultantId}")
    List<Userreviews> yonghupingjia(Integer id);
    List<Courses> fabukecheng(Integer id);
//    @Select("select * from consultants")
    List<Consultants> getconsultantMessage(Integer pageNum, Integer pageSize);
    List<Consultants> getconsultantMessageByName(@Param("consultantName") String consultantName,@Param("areaName") String areaName);
    @Select("select * from consultantlevels")
    List<Consultantlevels> getConsultantLevelList();
    @Insert("insert into consultants(consultant_name,region,level_name,consultant_introduction,consultant_photo) values(#{consultantName},#{region},#{levelName},#{consultantIntroduction},#{consultantPhoto})")
    int zixunshiAdd(@Param("consultantName") String consultantName,@Param("region")String region,@Param("levelName")String levelName,@Param("consultantIntroduction")String consultantIntroduction,@Param("consultantPhoto") String path);
    @Select("select consultant_id from consultants where consultant_name=#{consultantName}")
    Integer getConsultantId(String consultantName);
    @Select("select id from expertiseareas where area_name=#{levelName}")
    Integer getshanchanglingyuId(String levelName);
    @Insert("insert into consultant_expertiseareas(consultant_id,expertiseareas_id) values(#{consultantId},#{expertiseareasId})")
    int zixunshishanchanglingyuAdd(@Param("consultantId") Integer consultantId,@Param("expertiseareasId")Integer expertiseareasId);
    @Delete("delete from consultants where consultant_id = #{consultantId}")
    int zixunshiDelete(Integer consultantId);
    @Update("update consultants set consultant_name=#{consultantName},region=#{region},level_name=#{levelName},consultant_introduction=#{consultantIntroduction},consultant_photo=#{consultantPhoto} where consultant_id=#{consultantId}")
    int zixunshiUpdate(@Param("consultantId")Integer consultantId, @Param("consultantName") String consultantName,@Param("region")String region,@Param("levelName")String levelName,@Param("consultantIntroduction")String consultantIntroduction,@Param("consultantPhoto") String path);
    @Update("update consultant_expertiseareas set expertiseareas_id=#{expertiseareasId} where consultant_id=#{consultantId}")
    int zixunshishanchanglingyuUpdate(@Param("expertiseareasId")Integer expertiseareasId,@Param("consultantId") Integer consultantId);
    @Select("select id from consultant_expertiseareas where consultant_id = #{consultantId} and expertiseareas_id=#{expertiseareasId}")
    int getconsultantsexpertiseareasId(@Param("consultantId") Integer consultantId,@Param("expertiseareasId")Integer expertiseareasId);
}
